# This file is part of trytond-pcw-purchase module for Tryton. 
# The COPYRIGHT file at the top level of this repository contains 
# the full copyright notices and license terms.
from trytond.model import ModelSQL, ModelView, fields
from trytond.pyson import Eval, If, Bool, In
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta

__all__ = ['Product']
__metaclass__ = PoolMeta

class Product:
    __name__ = "product.product"

    salable = fields.Boolean('Salable', states={
            'readonly': ~Eval('active'),
            }, depends=['active'])
    sale_uom = fields.Many2One('product.uom', 'Sale UOM', states={
            'readonly': ~Eval('active'),
            'required': Eval('salable', False),
            },
        domain=[('category', '=', Eval('default_uom_category'))],
        depends=['active', 'salable', 'default_uom_category'])

    @staticmethod
    def default_salable():
        return False

